﻿
#include "ksff.h"
using namespace ksff;

/*

Библиотека для операций с файловой системой в операционной исстеме windows, а 
так же операций с именами файлов и директорий.


*/


int main()
{
	{
		bool res=false;

		res = is_file_exests("C:\\TEMP\\file.txt");
		res = is_file_exests(L"C:\\TEMP\\file.txt");
		res = is_directory_exests("C:\\TEMP\\");
		res = is_directory_exests(L"C:\\TEMPx\\");


		res =false;
	}


	{
		string ares;
		wstring wres;

		ares=  get_extention(  string("c:\\dir\\file.txt") );
		wres=  get_extention( wstring(L"c:\\dir\\file.txt") );

		ares=  set_extention(  string("c:\\dir\\file.txt"), "as");
		wres=  set_extention( wstring(L"c:\\dir\\file.txt"), L"as");

		ares=  get_directory(  string("c:\\dir\\file.txt") );
		wres=  get_directory( wstring(L"c:\\dir\\file.txt") );

		ares=  get_filename( string("c:\\dir\\file.txt") );
		wres=  get_filename( wstring(L"c:\\dir\\file.txt") );
			  

		ares="";
	}


	{

		 string adir, afile, aext;
		wstring wdir, wfile, wext;

		split( adir, afile, aext,   string(  "c:\\dir\\filetxt" ) );
		split( wdir, wfile, wext,  wstring( L"c:\\dir\\filetxt" ) );

		split( adir, afile, aext,   string(  "aaafile.txt" ) );
		split( wdir, wfile, wext,  wstring( L"aaafile.txt" ) );

		split( adir, afile, aext,   string(  "c:\\dir\\file.txt" ) );
		split( wdir, wfile, wext,  wstring( L"c:\\dir\\file.txt" ) );




		adir="";
	}

	{
		bool res = false;
		string adest  =  "c:\\dir1\\dir2\\dir3\\";
		wstring wdest = L"c:\\dir1\\dir2\\dir3\\";

		res = set_directory_up( adest );
		res = set_directory_up( adest );
		res = set_directory_up( adest );
		res = set_directory_up( adest );

		res = set_directory_up( wdest );
		res = set_directory_up( wdest );
		res = set_directory_up( wdest );
		res = set_directory_up( wdest );




		create_directory(   string("c:\\temp\\subdir\\")  );
		create_directory( wstring(L"c:\\temp\\subdir\\")  );


		res = false;
	}


	{
		string  ares;
		wstring wres;

		ares = get_fullpath(   string("c:\\temp\\file.txt")  );
		wres = get_fullpath(   wstring(L"c:\\temp\\file.txt") );

		ares = get_shortpath(  string("c:\\temp\\file.txt")  );
		wres = get_shortpath(  wstring(L"c:\\temp\\file.txt") );


		ares="";
	}

	{
		string  ares;
		wstring wres;

		ares = get_exe_fullpath_ansi();
		wres =  get_exe_fullpath_wide();

		ares = get_exe_directory_ansi();
		wres = get_exe_directory_wide();

		ares = get_module_directory_ansi( 0 );
		wres = get_module_directory_wide( 0 );


		ares="";
	}


	{

		bool res=false;
		string   adest;
		wstring  wdest;
		res = search_directory_up( adest,  "nsrch\\",  "c:\\temp\\sub\\" ) ;
		res = search_directory_up( wdest, L"nsrch\\", L"c:\\temp\\sub\\" ) ;

		std::vector<string>  avdest;
		std::vector<wstring> wvdest;

		search_files(avdest,   string("c:\\temp\\"),   string( "txt;dat"),  true );
		
		search_files(wvdest, wstring(L"c:\\temp\\"),   wstring(L"txt;dat"),  true );


	}


	{
		unsigned int data[4] = { 0xaabbccdd, 0xaabbccdd, 0xaabbccdd, 0xaabbccdd };
		save_to_file(data, 16,  "c:\\temp\\data.bin" )  ;
		save_to_file(data, 16, L"c:\\temp\\data.bin" )  ;

		std::vector<BYTE> dest;

		dest.clear();
		memset(data,0, sizeof(unsigned int)*4);
		load_from_file_binary( dest, "c:\\temp\\data.bin"  ) ;
		
		dest.clear();
		memset(data,0, sizeof(unsigned int)*4);
		load_from_file_binary( dest, L"c:\\temp\\data.bin" ) ;


		int _end = 0;
	}






	return  0;
}
